﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Alerts_Administration_2010.classes.views.templates
{
    public class StringTemplate : AlertViewTemplateBase
    {
        private TextBox _tb;
        private string _dataField;

        public StringTemplate(string dataField)
        {
            _dataField = dataField;
            _tb = new TextBox();
            _tb.ID = "{EF298687-0226-4696-8C71-06AF572CA8AD}";
        }

        protected override System.Web.UI.Control CreateControl()
        {
            return _tb;
        }

        protected override string GetBoundPropertyNames()
        {
            return _dataField;
        }

        protected override object GetValue(string propertyName)
        {
            return _tb.Text;
        }

        protected override void BindControl(DetailsViewItemBLL boundItem)
        {
            _tb.Text = (string)boundItem.GetType().GetProperty(_dataField).GetValue(boundItem,null);
        }
    }
}
